package com.lk.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lk.mall.mapper.GoodsCategoryMapper;
import com.lk.mall.model.entity.GoodsCategory;
import com.lk.mall.model.vo.CategoryVO;
import com.lk.mall.mapper.CategoryMapper;
import com.lk.mall.service.ICategoryService;
import com.lk.mall.util.PageQueryUtil;
import com.lk.mall.util.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lak
 * @since 2022-08-31
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, GoodsCategory> implements ICategoryService {

    @Resource
    GoodsCategoryMapper goodsCategoryMapper;

    @Override
    public PageResult<GoodsCategory> getCategory(PageQueryUtil pageQueryUtil) {
        List<GoodsCategory> goodsCategory = goodsCategoryMapper.getCategoryList(pageQueryUtil);

        int categoryTotal = goodsCategoryMapper.getCategoryTotal(pageQueryUtil);
        PageResult<GoodsCategory> categoryInfo = new PageResult<>(goodsCategory, categoryTotal,
                pageQueryUtil.getLimit(), pageQueryUtil.getPage());
        return categoryInfo;
    }
}
